package com.icim.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import javax.annotation.Resource;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.icim.rabbitmq.util.RabbitmqManager;
import com.icim.service.impl.LoadMainService;

public class TestMain {
	public static void main(String[] args) throws Exception {
		ApplicationContext ctx = new ClassPathXmlApplicationContext(
				new String[] { "applicationContext-rabbitmq.xml",
						"applicationContext-service.xml",
						"applicationContext.xml" });
		String str = "美帝";
		System.out.println(str);
		str = new String(str.getBytes(), "ISO8859-1");
		System.out.println(str);
		LoadMainService loadErrorMainService = (LoadMainService) ctx
				.getBean("loadErrorMainService");
//		loadErrorMainService.setHisQueueName("HIS_RET_PRD_INFO");
//		loadErrorMainService.setHisErrorQueueName("HIS_RET_PRD_INFO.ERR");
		loadErrorMainService.SubMainProc("<transaction><trans_cnt>1</trans_cnt><table><act_cmp_timestamp/><act_dps_qty>0</act_dps_qty><act_fth_dps_qty>0</act_fth_dps_qty><act_snd_dps_qty>0</act_snd_dps_qty><act_stb_timestamp/><act_trd_dps_qty>0</act_trd_dps_qty><bnd_box_flg>Y</bnd_box_flg><bnd_box_qty>3</bnd_box_qty><bnd_box_timestamp>2015-04-16 08:36:05.0</bnd_box_timestamp><bnd_fst_box_usr>01922</bnd_fst_box_usr><c_thickness>0.2</c_thickness><comp_prd_qty>0</comp_prd_qty><crt_timestamp>2015-04-16 08:23:23.0</crt_timestamp><crt_usr>01922</crt_usr><cus_id_fk>006</cus_id_fk><cus_info_fst/><cus_info_snd/><cus_rma_qty>0</cus_rma_qty><cut_mdl_id_fk/><dest_shop/><erp_bom_id/><erp_path_id/><erp_path_ver/><evt_timestamp>2015-04-16 09:22:25.0</evt_timestamp><evt_usr>01922</evt_usr><fm_mdl_id_fk>C7546G220</fm_mdl_id_fk><from_thickness>0.4</from_thickness><mdl_cate_fk>B</mdl_cate_fk><mdl_id_fk>C7546G220</mdl_id_fk><mtrl_lot_id_fk/><mtrl_part/><mtrl_prod_id_fk>C7546G220</mtrl_prod_id_fk><ok_ratio/><ope_eff_flg>Y</ope_eff_flg><ope_evt_name>XpwhsopeService</ope_evt_name><ope_evt_no>2C81INXMVAOE41SF1XN3S9HZI</ope_evt_no><ope_evt_node>192.168.2.200</ope_evt_node><ope_evt_usr>wg-mes-ser</ope_evt_usr><ope_tbl_name>RET_WO</ope_tbl_name><operation>IorU</operation><path_id_fk>DM0001</path_id_fk><path_ver_fk>00000</path_ver_fk><plant_id>TODO</plant_id><pln_cmp_date>2015-04-16</pln_cmp_date><pln_cmp_timestamp>2015-04-16 08:16:00.0</pln_cmp_timestamp><pln_prd_qty>43</pln_prd_qty><pln_stb_date>2015-04-16</pln_stb_date><pln_stb_timestamp>2015-04-16 08:16:00.0</pln_stb_timestamp><pv_unq_seq_id>880QDCZM0B6MUDQ24XOUPVQ2E</pv_unq_seq_id><rl_prd_qty>0</rl_prd_qty><rsv_dn_qty>0</rsv_dn_qty><rsv_dps_qty>0</rsv_dps_qty><rsv_fth_dps_qty>0</rsv_fth_dps_qty><rsv_pln_prd_qty>43</rsv_pln_prd_qty><rsv_snd_dps_qty>0</rsv_snd_dps_qty><rsv_trd_dps_qty>0</rsv_trd_dps_qty><scrp_prd_qty>0</scrp_prd_qty><sequence/><so_id>DQR20150478</so_id><sta_time_d>42110.3905784375</sta_time_d><str_ope_no>JB-01</str_ope_no><swh_cnt_flg/><t_thickness>0.2</t_thickness><th_mdl_id_fk/><to_thickness>0.4</to_thickness><unq_seq_id>905AWFRRLLDCRMTH09D3YW7KB</unq_seq_id><vcr_flg_fk/><wh_in_prd_qty>0</wh_in_prd_qty><wh_out_prd_qty>0</wh_out_prd_qty><wh_rwk_qty>0</wh_rwk_qty><wip_wh_in_prd_qty>0</wip_wh_in_prd_qty><wip_wh_out_prd_qty>0</wip_wh_out_prd_qty><wo_cate>RWP</wo_cate><wo_dsc/><wo_id>JD500643</wo_id><wo_note/><wo_prty/><wo_stat>WAIT</wo_stat><wo_typ>W</wo_typ></table></transaction>");
//		loadErrorMainService
//				.SubMainProc("<transaction><trans_cnt>1</trans_cnt><table><ac_recipe_id/><act_cmp_timestamp/><act_stb_timestamp>2015-03-25 00:46:00.0</act_stb_timestamp><batch_no/><bnk_flg>0</bnk_flg><box_id_fk/><c_rubbing_time>9</c_rubbing_time><cost_code/><cr_ope_id_fk>JB-10</cr_ope_id_fk><cr_ope_no_fk>JB-10</cr_ope_no_fk><cr_ope_ver_fk>00000</cr_ope_ver_fk><cr_path_id_fk>JBDM0001</cr_path_id_fk><cr_path_ver_fk>00000</cr_path_ver_fk><cr_proc_id_fk>JBQA</cr_proc_id_fk><cr_tool_id_fk>JB-4F-OQC-001</cr_tool_id_fk><cr_toolg_id_fk>G_JB10</cr_toolg_id_fk><cus_sn>11111111100000000000000000000000000000000000000000</cus_sn><def_code1/><def_code1_cnt/><def_code1_lc/><def_code1_sd/><def_code2/><def_code2_cnt/><def_code2_lc/><def_code2_sd/><def_code3/><def_code3_cnt/><def_code3_lc/><def_code3_sd/><def_code4/><def_code4_cnt/><def_code4_lc/><def_code4_sd/><def_code5/><def_code5_cnt/><def_code5_lc/><def_code5_sd/><dest_shop/><dn_no/><dps_id_fk/><ds_recipe_id/><evt_cate>PSTR</evt_cate><evt_dept/><evt_seq_id>EE7UGLMBVXSCYF8R6BDY40TCV</evt_seq_id><evt_time_d>42090.3775174537</evt_time_d><evt_timestamp>2015-03-27 09:03:37.0</evt_timestamp><evt_usr>05317</evt_usr><fab_id/><fab_sn>153090050206</fab_sn><fst_dps_id_fk/><fst_iqc_batch_id/><fst_judge_timestamp>2015-03-26 07:31:24.0</fst_judge_timestamp><fst_judge_tool_id>WG-PG-0077</fst_judge_tool_id><fst_logof_timestamp/><fst_logon_timestamp>2015-03-25 00:46:00.0</fst_logon_timestamp><fst_lot_id_fk/><fth_dps_id_fk/><fth_lot_id_fk/><group_id/><jge_ope_no_fk/><layot_id_fk>8*5_S</layot_id_fk><line_id/><logof_timestamp>2015-03-26 16:37:45.0</logof_timestamp><logof_usr>02735</logof_usr><logon_timestamp>2015-03-27 09:03:33.0</logon_timestamp><logon_usr>05317</logon_usr><lot_id>T21503240040R015</lot_id><lot_splt_id>00</lot_splt_id><mdl_cate_fk>AB</mdl_cate_fk><mdl_id_fk>C5550G270</mdl_id_fk><mdl_typ_fk>699*575</mdl_typ_fk><mtrl_box_id_fk>15309005M002</mtrl_box_id_fk><mtrl_grade_fk/><mtrl_lot_id_fk/><mtrl_pallet_id_fk/><mtrl_prod_id_fk>TM055JYSP34-20</mtrl_prod_id_fk><mtrl_slot_no_fk/><nx_ope_id_fk>JB-11</nx_ope_id_fk><nx_ope_no_fk>JB-11</nx_ope_no_fk><nx_ope_ver_fk>00000</nx_ope_ver_fk><nx_path_id_fk>JBDM0001</nx_path_id_fk><nx_path_ver_fk>00000</nx_path_ver_fk><nx_proc_id_fk>JBPK</nx_proc_id_fk><nx_tool_id_fk/><nx_toolg_id_fk>G_JB11</nx_toolg_id_fk><ope_evt_name>XpstartprocService</ope_evt_name><ope_evt_no>HXTFZMYVD8VQRZ67MK2LAII1</ope_evt_no><ope_evt_node>192.168.2.245</ope_evt_node><ope_evt_usr>WG</ope_evt_usr><ope_tbl_name>RET_PRD_INFO</ope_tbl_name><operation>IorUAL</operation><oqc_lotid/><oqc_skip_flg/><p1_timestamp>2015-03-27 09:03:37.0</p1_timestamp><p2_timestamp/><p3_timestamp/><p4_timestamp>2015-03-26 16:34:48.0</p4_timestamp><p5_timestamp/><p6_timestamp/><pallet_id/><prd_admin_flg>NNNNNNNNNNNNNNNNNNNN</prd_admin_flg><prd_grade/><prd_qty>40</prd_qty><prd_seq_id>153090050206</prd_seq_id><prd_seq_typ>S</prd_seq_typ><prd_stat>INPR</prd_stat><prd_std_qty>40</prd_std_qty><prd_swh_cnt/><prd_thickness>0.4</prd_thickness><prd_total_swh_cnt/><proc_cnt/><proc_flg>Y</proc_flg><prty/><pv_box_id_fk>15311030M004</pv_box_id_fk><pv_evt_timestamp/><pv_evt_usr/><pv_logof_timestamp>2015-03-26 07:31:25.0</pv_logof_timestamp><pv_logof_usr>02386</pv_logof_usr><pv_logon_timestamp>2015-03-26 08:02:45.0</pv_logon_timestamp><pv_logon_usr>04933</pv_logon_usr><pv_prd_grade>OK</pv_prd_grade><pv_prd_seq_id/><pv_prd_stat_fk>WAIT</pv_prd_stat_fk><pv_prd_thickness>0.0</pv_prd_thickness><pv_proc_id_fk/><pv_prty/><pv_slot_no/><pv_tool_id_fk/><pv_toolg_id_fk/><pv_unq_seq_id>8KJ6BM8DV7HPA4OY6M4RXLF4N</pv_unq_seq_id><pv_wo_id_fk/><qrs_ovr_flg>N</qrs_ovr_flg><relate_usr/><rma_no/><rsn_cate1/><rsn_cate2/><rsn_cate3/><rsn_cate4/><rsn_cate5/><rsn_code1/><rsn_code2/><rsn_code3/><rsn_code4/><rsn_code5/><rsn_dept1/><rsn_dept2/><rsn_dept3/><rsn_dept4/><rsn_dept5/><rsn_lc1/><rsn_lc2/><rsn_lc3/><rsn_lc4/><rsn_lc5/><rsv_no/><rubbing_typ/><sequence/><ship_box_id_fk/><shipping_timestamp/><sht_ope_msg/><slot_no>2</slot_no><snd_dps_id_fk/><snd_iqc_batch_id/><snd_judge_timestamp>2015-03-26 07:31:24.0</snd_judge_timestamp><snd_judge_tool_id>WG-PG-0077</snd_judge_tool_id><snd_lot_id_fk/><so_id_fk>DQR20150366</so_id_fk><sta_time_d>42090.377517939814</sta_time_d><sv_ope_id_fk/><sv_ope_no_fk/><sv_ope_ver_fk/><sv_path_id_fk/><sv_path_ver_fk/><t_rubbing_time>7</t_rubbing_time><tool_id_fk>JB-4F-OQC-001</tool_id_fk><tool_port_id_fk/><trd_dps_id_fk/><trd_iqc_batch_id/><trd_lot_id_fk/><unq_seq_id>1JO43MFPPT2F22LSYN4BJUTPI</unq_seq_id><wh_in_timestamp/><wo_id_fk>"
//						+ str
//						+ "</wo_id_fk><x_axis_cnt_fk>8</x_axis_cnt_fk><y_axis_cnt_fk>5</y_axis_cnt_fk></table></transaction>");
	}

	public static void main3(String[] args) {
		BufferedReader buffReader = null;
		FileReader fileReader = null;
		ApplicationContext ctx = new ClassPathXmlApplicationContext(
				new String[] { "applicationContext-rabbitmq.xml",
						"applicationContext-service.xml",
						"applicationContext.xml" });
//		LoadMainService loadErrorMainService = (LoadMainService) ctx
//				.getBean("loadErrorMainService");
//		loadErrorMainService.setHisQueueName("HIS_RET_PRD_INFO");
//		loadErrorMainService.setHisErrorQueueName("HIS_RET_PRD_INFO.ERR");
		
		RabbitmqManager rabbitmqManager = (RabbitmqManager) ctx
				.getBean("rabbitmqManager");
		int i =0;
//		try {
//			fileReader = new FileReader(new File("D:\\a.log"));
//			buffReader = new BufferedReader(fileReader);
//			String readLine = null;
//			while ((readLine = buffReader.readLine()) != null) {
//				System.out.println(i);
////				loadErrorMainService.SubMainProc(readLine);
//				rabbitmqManager.setMessage("HIS_RET_PRD_INFO", readLine);
//				i++;
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		} finally {
//			try {
//				fileReader.close();
//			} catch (IOException e) {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//			}
//			try {
//				buffReader.close();
//			} catch (IOException e) {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//			}
//		}
	}
}
